var str = location.href;
// alert(str);
// 获取当页面的Id
var arr = str.split("=");
// alert(arr[1]);

$(function(){
	$.ajax({
		type:"post",
		url:"/v1/website/product-detail",
		data:{id:arr[1]},
		dataType:"json",
		success:function (data){
			console.log(data);
			if(data.code == 200) {
				// 产品列表
				var list = data.data;
				var rateLsit = list.product;
				// alert(rateLsit)
				var htmlStr = '';
				// var productID = 
				// 图片
				var banner = list.cover_img;
				var bannerPic = '';
				// 产品列表数据
				// alert(rateLsit.title);
				
				
				// for(var i=0; i<rateLsit.length;i++){
					var kefuImg1 = rateLsit.custom1_img;
					var kefuImg2 = rateLsit.custom2_img;
					var kefuImg3 = rateLsit.custom3_img;
					if(kefuImg1 == ""){
						kefuImg1 = "../../img/websiteImg/MRserver.png"
					}if(kefuImg2 == ""){
						kefuImg2 = "../../img/websiteImg/MRserver.png"
					}if(kefuImg3 == ""){
						kefuImg3 = "../../img/websiteImg/MRserver.png"
					}
				// 判断有无抵押
				var YNDY = rateLsit.is_mortgage;
				if(rateLsit.is_mortgage == 0){
					YNDY = "无抵押"
				}else{
					YNDY = "有抵押"
				}	
					htmlStr =  
					
						'<div class="productItem">'
					+'<span class="rightLogo"><img src="../../img/websiteImg/bankRightLogo.png" " width="36" height="36"/></span>'
					+'<div class="productItemTop">'
					+'<div class="productItemTop1">'    		
					+'<span id="productItemTop1Lilv">'+ rateLsit.rate +'%</span>'
					
					+'<span id="roductItemTop1Title">'+ rateLsit.rate_label +'</span>'
					+'</div>'
					+'<div class="productItemTop2">'    		
					+'<div class="productItemTop2top">'    			
					+'<span id=""><img src="../../img/websiteImg/moneyProduct.png"/></span>'
					+'<span>可贷金额：'+ rateLsit.money+'</span>'
					+'</div>'
					+'<div class="productItemTop2mid">'    			
					+'<span id=""><img src="../../img/websiteImg/dayProduct.png"/></span>'    				
					+'<span>还款期限：'+ rateLsit.time_limit+'年</span>'
					+'</div>'
					+'<div class="productItemTop2bottom">'    			
					+'<span id=""><img src="../../img/websiteImg/diyaProduct.png"/></span>'    				
					+'<span>有无抵押：' + YNDY + '<span>(' + rateLsit.desc_mortgage + ')</span></span>'
					+'</div>'    			
					+'</div>'    		
					+'<div class="productItemTop3">'    		
					+'<img src=" ' + rateLsit.company_logo +'" alt=" '+ rateLsit.company_logo_alt +' " width="190" height="112"/>'    			
					+ '</div>'    		
					+ '</div>'    	
					+ '<div class="productItemBottom">'    	
					+'<div class="productItemBottom1">'    		
					+ '<img src=" ' + rateLsit.product_logo +'" alt=" '+ rateLsit.product_logo_alt +' "/>'    			
					+ '</div>'    		
					+ '<div class="productItemBottom2">'  		
					+ '<p>' + rateLsit.title + '</p>'
					+ '<div>' + rateLsit.content  +'</div>'
					+ '</div>'    		
					+ '<div class="productItemBottom3">'    		
					+ '<p>产品客服</p>'    			
					+ '<span><img src=" '+ kefuImg1 +'" alt=" '+ rateLsit.custom1_alt +' " width="44" height="44"/></span>'    			
					+ '<span><img src=" '+ kefuImg2 +'" alt=" '+ rateLsit.custom2_alt +' " width="44" height="44"/></span>'    			
					+ '<span><img src=" '+ kefuImg3 +'" alt=" '+ rateLsit.custom3_alt +' " width="44" height="44"/></span>'    			
					+ '<br />'   			
					+ '<div class="askNow"><a href="#" target="_blank">立即咨询</a></div>'   			
					+ '</div>'   	    
					+ '</div>'   	
					+ '</div>'   
					
					// 设置meta标签
					var descriptionMeta = rateLsit.desc;
					var keywordsMeta = rateLsit.keywords;
					
				}
				 $('.productItem').html(htmlStr);
				 $('.bannerProduct img').attr('src', banner);
				 $("meta[name='description']").attr('content', descriptionMeta);
				 $("meta[name='keywords']").attr('content', keywordsMeta);
				 // 4块div合并
				 $('.arts #ul').html(rateLsit.content);
				 $(".arts #ul").height('auto');
				 // alert(m.attr("content"))
				 
			},
		error: function (XMLHttpRequest) {
			if( XMLHttpRequest.status == 400)
			{
				location.href = "404.html";
			}
			else
			{
				location.href = "505.html";
			}
		}
			
			
			// }
			})
  })
  
